//
//  GQMainNavigationController.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/11.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//

#import "GQMainNavigationController.h"
#import "GQTabBar.h"

@interface GQMainNavigationController () <UINavigationControllerDelegate>

@property (strong, nonatomic) id popDelegate;

@end

@implementation GQMainNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:17]}];
    self.navigationBar.barTintColor = kNavigationBarColor;
    _popDelegate = self.interactivePopGestureRecognizer.delegate;
    self.delegate = self;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.childViewControllers.count) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

-  (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{

    if (self.childViewControllers.count > 1) {
        [GQTabBar sharedGQTabBar].hidden = YES;
    }else{
        [GQTabBar sharedGQTabBar].hidden = NO;
    }
    
}

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (viewController == self.viewControllers[0]) {
        self.interactivePopGestureRecognizer.delegate = nil;
    }else{
        self.interactivePopGestureRecognizer.delegate = _popDelegate;
    }
}
@end
